<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增附件')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-programFile-add">
        <input name="relateId"  type="hidden"  th:value="${relateId}">
        <input name="relateMode"  type="hidden"  th:value="${relateMode}">
        <input name="urls" id="urls"  type="hidden">
        <input name="fileNames"  id="fileNames"  type="hidden">
        <input name="newFileNames"  id="newFileNames" type="hidden">
        <input name="originalFilenames" id="originalFilenames"  type="hidden">
        <div class="form-group">
            <label class="font-noraml">多文件上传</label>
            <div class="file-loading">
                <input id="multipleFile" name="files" type="file" multiple>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">



</script>
<script th:inline="javascript">
    $(document).ready(function () {
        // 多图上传
        $("#multipleFile").fileinput({
            uploadUrl: ctx + 'common/uploads',
            uploadAsync: false
        }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return urls：" + rsp.urls)
            log.info("reutrn fileNames：" + rsp.fileNames)
            log.info("reutrn newFileNames：" + rsp.newFileNames)
            log.info("return originalFilenames：" + rsp.originalFilenames)
            $("#urls").val(rsp.urls)
            $("#fileNames").val(rsp.fileNames)
            $("#newFileNames").val(rsp.newFileNames)
            $("#originalFilenames").val(rsp.originalFilenames)

        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    });

    var prefix = ctx + "cd/programItem"
    $("#form-programFile-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/batchAdd", $('#form-programFile-add').serialize());
        }
    }
</script>
</body>
</html>
